package edu.uta.BillMeApp;

import edu.uta.BillMeApp.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
/* @auther Siddharth Patel & Susan Foster */
public class MakePayment extends Activity{
	
	EditText amount, description;
    Button selectF,back;
    TextView userName;
    String getWN;
    DatePicker date;
    CheckBox check;
    String s="";
    String c="";
    String getUN;
    
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item);
       
        description=(EditText)findViewById(R.id.description);
        amount=(EditText)findViewById(R.id.billAmt);
        selectF=(Button)findViewById(R.id.submitBillBtn);
        back=(Button)findViewById(R.id.back1);
        date=(DatePicker)findViewById(R.id.dateOfEf);
        userName=(TextView)findViewById(R.id.userText);
        check=(CheckBox)findViewById(R.id.monthlyPay);
          
        int y=date.getYear();
        int m=date.getMonth();
        int d=date.getDayOfMonth();
        String year=Integer.toString(y);
        String month=Integer.toString(m);
        String day=Integer.toString(d);
        s=year.concat("-".concat(month.concat("-".concat(day))));
        
        if(check.isChecked()){
        	c="1";
        }
        else{
        	c="0";
        }
        
        Bundle gotBundle=getIntent().getExtras();
        getWN=gotBundle.getString("wN");
        userName.setText("User: ".concat(getWN));

        selectF.setOnClickListener(new View.OnClickListener() {

			public void onClick(View view) {
				// TODO Auto-generated method stub
				
				Bundle bundle = new Bundle();
				String flag = "0";
				bundle.putString("flag",flag);
				bundle.putString("user",getWN);
				bundle.putString("amount",amount.getText().toString());
				bundle.putString("desc",description.getText().toString());
				bundle.putString("date",s);
				bundle.putString("MF",c);
				Intent nextPage = new Intent(view.getContext(),ShareBill.class);
				nextPage.putExtras(bundle);
				startActivity(nextPage);
        
			}
			});
        
        back.setOnClickListener(new View.OnClickListener() {

			public void onClick(View view) {
				// TODO Auto-generated method stub
				
				Bundle bundle = new Bundle();
				bundle.putString("wN",getWN);
				Intent nextPage = new Intent(view.getContext(),TableOfCont.class);
				nextPage.putExtras(bundle);
				startActivity(nextPage);
        
			}
			});

	}//end onCreate
        
        }//end class
